Opensky

OpenSky provides api to get data for flights in progress. It is rate limited

Code
import requests
import pandas as pd
import geopandas
Code
def fetch_opensky_data():
    url = "https://opensky-network.org/api/states/all"
    response = requests.get(url)
    data = response.json()

    columns = [
        "icao24", "callsign", "origin_country", "time_position", "last_contact",
        "longitude", "latitude", "baro_altitude", "on_ground", "velocity",
        "heading", "vertical_rate", "sensors", "geo_altitude", "squawk",
        "spi", "position_source"
    ]

    df_raw = pd.DataFrame(data['states'], columns=columns)
    return (
        df_raw
        .assign(
            time_position=pd.to_datetime(df_raw["time_position"], unit="s"),
            last_contact=pd.to_datetime(df_raw["last_contact"], unit="s"),
        )
    )

df_flights = fetch_opensky_data()


df_flihts_non_nan = df_flights.dropna(subset=["longitude", "latitude"])
gdf = geopandas.GeoDataFrame(
    df_flihts_non_nan,
    geometry=geopandas.points_from_xy(df_flihts_non_nan.longitude, df_flihts_non_nan.latitude),
    crs="EPSG:4326",
)

gdf.explore(fullscreen=True, tooltip=False, popup=True)
Make this Notebook Trusted to load map: File -> Trust Notebook

Flights in world at notebook time

Number of flights by origin_country

Code
(
    df_flights
    .groupby("origin_country")
    .agg(num_flights=("icao24", "count"))
    .sort_values("num_flights", ascending=False)
    .head(20)
)
num_flights
origin_country
United States 4669
United Kingdom 340
Canada 325
Ireland 228
Turkey 140
Germany 124
China 118
United Arab Emirates 113
Australia 106
Malta 104
Spain 102
Brazil 91
India 88
Kingdom of the Netherlands 82
France 76
Mexico 65
Austria 61
Japan 58
New Zealand 56
Sweden 54

Top 20 countries with most flights

All flights

For reference

Code
df_flights
icao24 callsign origin_country time_position last_contact longitude latitude baro_altitude on_ground velocity heading vertical_rate sensors geo_altitude squawk spi position_source
0 ab1644 UAL8191 United States 2025-05-17 21:23:51 2025-05-17 21:23:52 -77.9301 35.3311 11262.36 False 198.84 357.03 0.33 None 11711.94 7046 False 0
1 a1abf5 N2069W United States 2025-05-17 21:23:15 2025-05-17 21:23:15 -90.5551 14.5664 1653.54 False 69.18 312.59 3.58 None 1729.74 1601 False 0
2 e8027d LPE2454 Chile 2025-05-17 21:19:15 2025-05-17 21:19:19 -86.9373 21.0897 381.00 False 72.06 123.35 -3.58 None 396.24 None False 0
3 39de4a TVF86LY France 2025-05-17 21:23:52 2025-05-17 21:23:52 -7.8084 35.5199 11879.58 False 208.47 178.02 -0.33 None 12207.24 7644 False 0
4 801641 AXB698 India 2025-05-17 21:23:52 2025-05-17 21:23:52 53.1650 25.1998 10668.00 False 241.39 121.05 0.00 None 11338.56 None False 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
7872 7c4807 OIH Australia 2025-05-17 21:23:52 2025-05-17 21:23:52 153.5465 -28.1436 1767.84 False 84.43 333.59 -12.03 None 1866.90 1733 False 0
7873 4caa32 ITY619 Ireland 2025-05-17 21:23:51 2025-05-17 21:23:51 -77.4537 38.9467 NaN True 5.40 270.00 NaN None NaN None False 0
7874 458664 CAT750 Denmark 2025-05-17 21:23:52 2025-05-17 21:23:52 21.8020 45.8280 11582.40 False 233.05 330.95 0.00 None 11551.92 None False 0
7875 458666 CAT9752 Denmark 2025-05-17 21:23:52 2025-05-17 21:23:52 15.7253 52.3409 12192.00 False 230.90 327.37 0.00 None 12123.42 4532 False 0
7876 458665 CAT314 Denmark 2025-05-17 21:23:52 2025-05-17 21:23:52 6.4021 46.4385 11582.40 False 201.63 350.01 0.00 None 11719.56 5334 False 0

7877 rows × 17 columns